import Vue from "vue";

import Vuex from "vuex";
import persistence from "vuex-uniapp-persistence";

import user from "@/store/modules/user";
import getters from "./getters";

Vue.use(Vuex);
// 数据持久化

const store = new Vuex.Store({
  plugins: [persistence()],
  state: {
    safeArea: uni.getWindowInfo().safeArea,
    // capsule: uni.getMenuButtonBoundingClientRect(),
    platform: uni.getSystemInfoSync().platform,
    // 用户切换标识
    userType: "1",
    //标识是否为扫码用户 isScan:0 不是扫码进来，1是
    scanStatus: { storeId: "", isScan: 0, phonenumber: "" },
    // 保存金刚区path参数
    pathData: [],
  },
  getters,
  mutations: {
    setUserType(state, params) {
      state.userType = params;
    },
    steScanStatus(state, params) {
      state.scanStatus = params;
    },
    setPathData(state, params) {
 
      console.log(params, "传进来的值");
      state.pathData = params;
    },
  },
  actions: {
    
    // 判断扫码进入首页
    IsRecruit(type) {
      if (type.state.userType === "1") {
        console.log(type.state, '求职端');
        wx.setTabBarItem({
          index: 0,
          text: "首页",
          iconPath: "static/images/recruit/company-sele(1).png",
          selectedIconPath: "static/images/recruit/company-sele.png",
        });
        wx.setTabBarItem({
          index: 1,
          text: "岗位",
          iconPath: "static/images/recruit/company-sele(3).png",
          selectedIconPath: "static/images/recruit/company-sele(2).png",
        });
        wx.setTabBarItem({
          index: 2,
          text: "消息",
          iconPath: "static/images/recruit/company-sele(5).png",
          selectedIconPath: "static/images/recruit/company-sele(4).png",
        });
        wx.setTabBarItem({
          index: 3,
          text: "我的",
          iconPath: "static/images/recruit/company-sele(9).png",
          selectedIconPath: "static/images/recruit/company-sele(8).png",
        });
      } else {
        console.log(type.state, '企业端');
        wx.setTabBarItem({
          index: 0,
          text: "首页",
          iconPath: "static/images/recruit/company-sele(1).png",
          selectedIconPath: "static/images/recruit/company-sele.png",
        });
        wx.setTabBarItem({
          index: 1,
          text: "人才",
          iconPath: "static/images/recruit/company-sele(7).png",
          selectedIconPath: "static/images/recruit/company-sele(6).png",
        });
        wx.setTabBarItem({
          index: 2,
          text: "岗位",
          iconPath: "static/images/recruit/company-sele(3).png",
          selectedIconPath: "static/images/recruit/company-sele(2).png",
        });
        wx.setTabBarItem({
          index: 3,
          text: "我的",
          iconPath: "static/images/recruit/company-sele(9).png",
          selectedIconPath: "static/images/recruit/company-sele(8).png",
        });
      }
    }
  },
  modules: {
    user,
  },
});
export default store;
